﻿Public Partial Class Wfrm_Mostrar_Prueba
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            ViewState("ID_PRUEBA_EJECUCION") = 1 ' este parametro se debe pasar cuando el alumno ingresa a dar la prueba.
            ViewState("K_PRUEBA") = 7
            CargaInicial(ViewState("K_PRUEBA"))
        End If
        GetPreguntas()

    End Sub

    Sub CargaInicial(ByVal Id_Prueba As String)
        Dim rp As New DotNetResponse.SQLPersistence
        Dim Exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)

        ' DalAppTestBuilder.TB_PRUEBA_DISENO.SELECCIONA_PRUEBA_DISENNO_PK(rp, Exec, Id_Prueba, "jquintanilla")
        Exec.Dispose()

        If rp.TieneDatos Then
            lbl_titulo_prueba.Text = rp.DtTable.Rows(0).Item("S_NOMBRE_PRUEBA")
        End If

        Dim rpexec As New DotNetResponse.SQLPersistence

        'Dim Cargar 'As New DalAppTestBuilder.TB_GENERICA
        'Cargar.CargarGrilla(rpexec, GridSecciones, "select P_SECCION,S_NOMBRE_SECCION , I_PUNTOS ,I_NRO_SECCION, s_observacion   from TB_PRUEBA_DISENO_SECCION where k_PRUEBA =" & Id_Prueba)

        If rpexec.TieneDatos Then
            Dim i As Integer
            For i = 0 To rpexec.DtTable.Rows.Count - 1
                Dim k As Integer
                For k = 0 To GridSecciones.Items.Count - 1
                    If rpexec.DtTable.Rows(i).Item(0) = GridSecciones.Items(k).Cells(2).Text Then
                        DirectCast(DirectCast(DirectCast(GridSecciones.Items(k).Cells(1), System.Web.UI.WebControls.TableCell).Controls(1), System.Web.UI.Control), Anthem.LinkButton).Text = GridSecciones.Items(k).Cells(3).Text
                        DirectCast(DirectCast(DirectCast(GridSecciones.Items(k).Cells(1), System.Web.UI.WebControls.TableCell).Controls(1), System.Web.UI.Control), Anthem.LinkButton).CommandArgument = GridSecciones.Items(k).Cells(2).Text
                        DirectCast(DirectCast(DirectCast(GridSecciones.Items(k).Cells(1), System.Web.UI.WebControls.TableCell).Controls(1), System.Web.UI.Control), Anthem.LinkButton).EnabledDuringCallBack = False
                        DirectCast(DirectCast(DirectCast(GridSecciones.Items(k).Cells(1), System.Web.UI.WebControls.TableCell).Controls(1), System.Web.UI.Control), Anthem.LinkButton).EnableCallBack = True
                        DirectCast(DirectCast(DirectCast(GridSecciones.Items(k).Cells(1), System.Web.UI.WebControls.TableCell).Controls(1), System.Web.UI.Control), Anthem.LinkButton).UpdateAfterCallBack = True
                    End If
                Next
            Next
        End If
    End Sub
    Sub GetPreguntas()

        If ViewState("P_SECCION") Is Nothing Or ViewState("K_PRUEBA") Is Nothing Then
            Exit Sub
        End If

        tbl_preguntas.Rows.Clear()
        tbl_preguntas.UpdateAfterCallBack = True

        Dim rp As New DotNetResponse.SQLPersistence
        Dim Exec As New CLS_Ejecucion_Preguntas
        Exec.GetRespuesta(rp, ViewState("K_PRUEBA"), ViewState("P_SECCION"))

        Dim i As Integer
        If rp.TieneDatos Then
            For i = 0 To rp.DtTable.Rows.Count - 1

                Dim celda As New TableCell
                Dim celda2 As New TableCell

                Dim fila1 As New TableRow
                fila1.Style.Add("border-bottom-style", "solid")
                fila1.Style.Add("border-bottom-width", "3px")

                Dim lbl_nro_pregunta As New Anthem.Label
                lbl_nro_pregunta.Text = "" 'rp.DtTable.Rows(i).Item("I_NRO_PREGUNTA").ToString
                lbl_nro_pregunta.Font.Bold = True
                lbl_nro_pregunta.Font.Size = FontUnit.Point(16)
                lbl_nro_pregunta.Font.Underline = True
                lbl_nro_pregunta.UpdateAfterCallBack = True
                lbl_nro_pregunta.UpdateAfterCallBack = True
                celda.Controls.Add(lbl_nro_pregunta)

                Dim lbl_texto_Pregunta As New Anthem.Label
                lbl_texto_Pregunta.Text = (rp.DtTable.Rows(i).Item("S_DESCRIPCION_PREGUNTA").ToString)
                'HttpUtility.HtmlEncode()

                celda2.Controls.Add(lbl_texto_Pregunta)

                celda2.VerticalAlign = VerticalAlign.Bottom
                celda.VerticalAlign = VerticalAlign.Top

                'celda.Style.Add("border-top-style", "solid")
                'celda.Style.Add("border-top-width", "3px")
                'celda2.Style.Add("border-top-style", "solid")
                'celda2.Style.Add("border-top-width", "3px")

                tbl_preguntas.CellPadding = 5
                tbl_preguntas.CellSpacing = 5

                fila1.Style.Add("border-top-width", "3px")
               
                fila1.Cells.Add(celda)
                fila1.Cells.Add(celda2)
                tbl_preguntas.Rows.Add(fila1)

                If rp.DtTable.Rows(i).Item("S_URL_IMAGEN").ToString.Length > 0 Then
                    Dim imag As New Anthem.Image
                    imag.ImageUrl = rp.DtTable.Rows(i).Item("S_URL_IMAGEN").ToString
                    imag.UpdateAfterCallBack = True

                    Dim flimg As New TableRow
                    Dim celimg As New TableCell
                    celimg.ColumnSpan = 2
                    celimg.Controls.Add(imag)
                    flimg.Controls.Add(celimg)

                    tbl_preguntas.Controls.Add(flimg)

                End If
                tbl_preguntas.Width = Unit.Pixel(600)

                GeneraAlternativas(rp.DtTable.Rows(i).Item("P_PREGUNTA").ToString, rp.DtTable.Rows(i).Item("K_TIPO_PREGUNTA").ToString)
                tbl_preguntas.UpdateAfterCallBack = True



            Next


        End If

        tbl_preguntas.UpdateAfterCallBack = True

        ' ViewState("P_SECCION") = Nothing
        ' ViewState("K_PRUEBA") = Nothing
         
    End Sub
#Region "Generacion de Alternativas"
    Sub GeneraAlternativas(ByVal K_pregunta As Decimal, ByVal TipoPregunta As Integer)
        '[SP_OBTIENE_PRUEBA_DISENO_RESPUESTA]

        Dim Execute As New CLS_DISENIO_ALTERNATIVA
        Dim rp As New DotNetResponse.SQLPersistence

        Execute.GetAlternativa(rp, K_pregunta)

        If rp.TieneDatos Then
            Select Case TipoPregunta
                Case 1
                    GeneraAlternativasCorrectas(rp)
                Case 3
                    GeneraAlternativaCorrecta(rp)

                Case 8
                    GeneraAlternativaCorrectaConImagen(rp)

            End Select

        End If

    End Sub

    Sub GeneraAlternativasCorrectas(ByRef rp As DotNetResponse.SQLPersistence)
        If rp.TieneDatos Then


            Dim i As Integer
            Dim tbRespuesta As New Anthem.Table

            For i = 0 To rp.DtTable.Rows.Count - 1
                Dim celda0 As New TableCell
                celda0.ColumnSpan = 2

                Dim celda As New TableCell
                Dim celda2 As New TableCell

                Dim celdar1 As New TableCell
                Dim celdar2 As New TableCell
                Dim celdar3 As New TableCell
                Dim celdar4 As New TableCell
                Dim celdar5 As New TableCell

                celdar1.HorizontalAlign = HorizontalAlign.Left
                celdar2.HorizontalAlign = HorizontalAlign.Left
                celdar3.HorizontalAlign = HorizontalAlign.Left
                celdar4.HorizontalAlign = HorizontalAlign.Left
                celdar5.HorizontalAlign = HorizontalAlign.Left

                celdar1.BorderStyle = BorderStyle.Solid
                celdar1.BorderWidth = 1
                celdar1.BorderColor = Drawing.Color.Black

                celdar1.BorderStyle = BorderStyle.Solid
                celdar1.BorderWidth = 1
                celdar1.BorderColor = Drawing.Color.Black

                celdar2.BorderStyle = BorderStyle.Solid
                celdar2.BorderWidth = 1
                celdar2.BorderColor = Drawing.Color.Black


                celdar3.BorderStyle = BorderStyle.Solid
                celdar3.BorderWidth = 1
                celdar3.BorderColor = Drawing.Color.Black


                celdar4.BorderStyle = BorderStyle.Solid
                celdar4.BorderWidth = 1
                celdar4.BorderColor = Drawing.Color.Black


                celdar5.BorderStyle = BorderStyle.Solid
                celdar5.BorderWidth = 1
                celdar5.BorderColor = Drawing.Color.Black



                Dim fila1 As New TableRow
                Dim lbl_nro_pregunta As New Anthem.Label
                Dim lbl_r1 As New Anthem.Label
                Dim lbl_r2 As New Anthem.Label
                Dim lbl_r3 As New Anthem.Label
                Dim lbl_r4 As New Anthem.Label
                Dim lbl_r5 As New Anthem.Label



                lbl_nro_pregunta.Text = rp.DtTable.Rows(i).Item("i_fila").ToString

                'lbl_nro_pregunta.Font.Bold = True
                'lbl_nro_pregunta.Font.Size = FontUnit.Point(14)
                'lbl_nro_pregunta.UpdateAfterCallBack = True
                celda.Controls.Add(lbl_nro_pregunta)

                Dim chk1 As New Anthem.CheckBox
                AddHandler chk1.CheckedChanged, AddressOf chk
                chk1.SkinID = rp.DtTable.Rows(i).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(i).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              
                celda2.Controls.Add(chk1)

                lbl_r1.Text = rp.DtTable.Rows(i).Item("s_r1").ToString
                lbl_r2.Text = rp.DtTable.Rows(i).Item("s_r2").ToString
                lbl_r3.Text = rp.DtTable.Rows(i).Item("s_r3").ToString
                lbl_r4.Text = rp.DtTable.Rows(i).Item("s_r4").ToString
                lbl_r5.Text = rp.DtTable.Rows(i).Item("s_r5").ToString
                lbl_r1.UpdateAfterCallBack = True
                lbl_r2.UpdateAfterCallBack = True
                lbl_r3.UpdateAfterCallBack = True
                lbl_r4.UpdateAfterCallBack = True
                lbl_r5.UpdateAfterCallBack = True

                celdar1.Controls.Add(lbl_r1)
                celdar2.Controls.Add(lbl_r2)
                celdar3.Controls.Add(lbl_r3)
                celdar4.Controls.Add(lbl_r4)
                celdar5.Controls.Add(lbl_r5)

                Dim fl As New TableRow
                fl.Cells.Add(celda)
                fl.Cells.Add(celda2)
                fl.Cells.Add(celdar1)
                fl.Cells.Add(celdar2)
                fl.Cells.Add(celdar3)
                fl.Cells.Add(celdar4)
                fl.Cells.Add(celdar5)

                tbRespuesta.Rows.Add(fl)

                tbRespuesta.CellPadding = 4
                tbRespuesta.CellSpacing = 4

                tbRespuesta.UpdateAfterCallBack = True
                celda0.Controls.Add(tbRespuesta)
                fila1.Cells.Add(celda0)

                tbl_preguntas.Rows.Add(fila1)
            Next

            tbl_preguntas.UpdateAfterCallBack = True
        End If

    End Sub


    Sub GeneraAlternativaCorrecta(ByRef rp As DotNetResponse.SQLPersistence)
        If rp.TieneDatos Then


            Dim i As Integer
            Dim tbRespuesta As New Anthem.Table

            For i = 0 To rp.DtTable.Rows.Count - 1
                Dim celda0 As New TableCell
                celda0.ColumnSpan = 2

                Dim celda As New TableCell
                Dim celda2 As New TableCell

                Dim celdar1 As New TableCell
                Dim celdar2 As New TableCell
                Dim celdar3 As New TableCell
                Dim celdar4 As New TableCell
                Dim celdar5 As New TableCell

                celdar1.HorizontalAlign = HorizontalAlign.Left
                celdar2.HorizontalAlign = HorizontalAlign.Left
                celdar3.HorizontalAlign = HorizontalAlign.Left
                celdar4.HorizontalAlign = HorizontalAlign.Left
                celdar5.HorizontalAlign = HorizontalAlign.Left

                'celdar1.BorderStyle = BorderStyle.Solid
                'celdar1.BorderWidth = 1
                'celdar1.BorderColor = Drawing.Color.Black

                'celdar1.BorderStyle = BorderStyle.Solid
                'celdar1.BorderWidth = 1
                'celdar1.BorderColor = Drawing.Color.Black

                'celdar2.BorderStyle = BorderStyle.Solid
                'celdar2.BorderWidth = 1
                'celdar2.BorderColor = Drawing.Color.Black


                'celdar3.BorderStyle = BorderStyle.Solid
                'celdar3.BorderWidth = 1
                'celdar3.BorderColor = Drawing.Color.Black


                'celdar4.BorderStyle = BorderStyle.Solid
                'celdar4.BorderWidth = 1
                'celdar4.BorderColor = Drawing.Color.Black


                'celdar5.BorderStyle = BorderStyle.Solid
                'celdar5.BorderWidth = 1
                'celdar5.BorderColor = Drawing.Color.Black



                Dim fila1 As New TableRow
                Dim lbl_nro_pregunta As New Anthem.Label
                Dim lbl_r1 As New Anthem.Label
                Dim lbl_r2 As New Anthem.Label
                Dim lbl_r3 As New Anthem.Label
                Dim lbl_r4 As New Anthem.Label
                Dim lbl_r5 As New Anthem.Label



                lbl_nro_pregunta.Text = rp.DtTable.Rows(i).Item("i_fila").ToString

                'lbl_nro_pregunta.Font.Bold = True
                'lbl_nro_pregunta.Font.Size = FontUnit.Point(14)
                'lbl_nro_pregunta.UpdateAfterCallBack = True
                celda.Controls.Add(lbl_nro_pregunta)

                Dim chk1 As New Anthem.CheckBox
                AddHandler chk1.CheckedChanged, AddressOf chk
                chk1.SkinID = rp.DtTable.Rows(i).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(i).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              
                celda2.Controls.Add(chk1)

                lbl_r1.Text = rp.DtTable.Rows(i).Item("s_r1").ToString
                lbl_r2.Text = rp.DtTable.Rows(i).Item("s_r2").ToString
                lbl_r3.Text = rp.DtTable.Rows(i).Item("s_r3").ToString
                lbl_r4.Text = rp.DtTable.Rows(i).Item("s_r4").ToString
                lbl_r5.Text = rp.DtTable.Rows(i).Item("s_r5").ToString
                lbl_r1.UpdateAfterCallBack = True
                lbl_r2.UpdateAfterCallBack = True
                lbl_r3.UpdateAfterCallBack = True
                lbl_r4.UpdateAfterCallBack = True
                lbl_r5.UpdateAfterCallBack = True

                celdar1.Controls.Add(lbl_r1)
                celdar2.Controls.Add(lbl_r2)
                celdar3.Controls.Add(lbl_r3)
                celdar4.Controls.Add(lbl_r4)
                celdar5.Controls.Add(lbl_r5)

                Dim fl As New TableRow
                fl.Cells.Add(celda)
                fl.Cells.Add(celda2)
                fl.Cells.Add(celdar1)
                fl.Cells.Add(celdar2)
                fl.Cells.Add(celdar3)
                fl.Cells.Add(celdar4)
                fl.Cells.Add(celdar5)

                tbRespuesta.Rows.Add(fl)

                tbRespuesta.CellPadding = 6
                tbRespuesta.CellSpacing = 6

                tbRespuesta.UpdateAfterCallBack = True
                celda0.Controls.Add(tbRespuesta)
                fila1.Cells.Add(celda0)

                tbl_preguntas.Rows.Add(fila1)
            Next

            tbl_preguntas.UpdateAfterCallBack = True
        End If

    End Sub



    Sub GeneraAlternativaCorrectaConImagen(ByRef rp As DotNetResponse.SQLPersistence)
        'If rp.TieneDatos Then

        Dim i As Integer
        Dim tbAlternativa As New Anthem.Table

        Dim fila1 As New TableRow
        Dim fila2 As New TableRow

        Dim celda0 As New TableCell
        celda0.ColumnSpan = 2

        Dim celda As New TableCell
        Dim celda2 As New TableCell

        Dim celda1_1 As New TableCell
        Dim celda1_2 As New TableCell
        Dim celda1_3 As New TableCell
        Dim celda1_4 As New TableCell

        Dim celda2_1 As New TableCell
        Dim celda2_2 As New TableCell
        Dim celda2_3 As New TableCell
        Dim celda2_4 As New TableCell

        Dim lbl_nro_pregunta As New Anthem.Label
        lbl_nro_pregunta.Text = rp.DtTable.Rows(0).Item("i_fila").ToString


        Dim lbl_r1 As New Anthem.Image
        Dim lbl_r2 As New Anthem.Image
        Dim lbl_r3 As New Anthem.Image
        Dim lbl_r4 As New Anthem.Image
        Dim lbl_r5 As New Anthem.Image

        Dim chk1 As New Anthem.CheckBox
        AddHandler chk1.CheckedChanged, AddressOf chk
        chk1.SkinID = rp.DtTable.Rows(0).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(0).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              

        Dim chk2 As New Anthem.CheckBox
        AddHandler chk2.CheckedChanged, AddressOf chk
        chk2.SkinID = rp.DtTable.Rows(1).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(1).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              


        Dim chk3 As New Anthem.CheckBox
        AddHandler chk3.CheckedChanged, AddressOf chk
        chk3.SkinID = rp.DtTable.Rows(2).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(2).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              

        Dim chk4 As New Anthem.CheckBox
        AddHandler chk4.CheckedChanged, AddressOf chk
        chk4.SkinID = rp.DtTable.Rows(3).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(3).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              


        lbl_r1.ImageUrl = rp.DtTable.Rows(0).Item("s_ruta1").ToString
        lbl_r2.ImageUrl = rp.DtTable.Rows(1).Item("s_ruta1").ToString
        lbl_r3.ImageUrl = rp.DtTable.Rows(2).Item("s_ruta1").ToString
        lbl_r4.ImageUrl = rp.DtTable.Rows(3).Item("s_ruta1").ToString
        'lbl_r5.ImageUrl = rp.DtTable.Rows(4).Item("s_ruta5").ToString


        lbl_r1.UpdateAfterCallBack = True
        lbl_r2.UpdateAfterCallBack = True
        lbl_r3.UpdateAfterCallBack = True
        lbl_r4.UpdateAfterCallBack = True
        'lbl_r5.UpdateAfterCallBack = True


        celda1_1.Controls.Add(chk1)
        celda1_2.Controls.Add(lbl_r1)

        celda1_3.Controls.Add(chk2)
        celda1_4.Controls.Add(lbl_r2)


        celda2_1.Controls.Add(chk3)
        celda2_2.Controls.Add(lbl_r3)

        celda2_3.Controls.Add(chk4)
        celda2_4.Controls.Add(lbl_r4)


        fila1.Controls.Add(celda1_1)
        fila1.Controls.Add(celda1_2)
        fila1.Controls.Add(celda1_3)
        fila1.Controls.Add(celda1_4)

        fila2.Controls.Add(celda2_1)
        fila2.Controls.Add(celda2_2)
        fila2.Controls.Add(celda2_3)
        fila2.Controls.Add(celda2_4)


        tbAlternativa.Rows.Add(fila1)
        tbAlternativa.Rows.Add(fila2)

        tbAlternativa.CellPadding = 4
        tbAlternativa.CellSpacing = 4

        tbAlternativa.UpdateAfterCallBack = True
        celda0.Controls.Add(tbAlternativa)
        Dim fl As New TableRow
        fl.Cells.Add(celda0)

        tbl_preguntas.Rows.Add(fl)


        tbl_preguntas.UpdateAfterCallBack = True



        '    For i = 0 To rp.DtTable.Rows.Count - 1



        '        Dim celdar1 As New TableCell
        '        Dim celdar2 As New TableCell
        '        Dim celdar3 As New TableCell
        '        Dim celdar4 As New TableCell
        '        Dim celdar5 As New TableCell

        '        celdar1.HorizontalAlign = HorizontalAlign.Left
        '        celdar2.HorizontalAlign = HorizontalAlign.Left
        '        celdar3.HorizontalAlign = HorizontalAlign.Left
        '        celdar4.HorizontalAlign = HorizontalAlign.Left
        '        celdar5.HorizontalAlign = HorizontalAlign.Left


        '        Dim fila1 As New TableRow

        '        Dim lbl_r1 As New Anthem.Image
        '        Dim lbl_r2 As New Anthem.Image
        '        Dim lbl_r3 As New Anthem.Image
        '        Dim lbl_r4 As New Anthem.Image
        '        Dim lbl_r5 As New Anthem.Image



        '        celda.Controls.Add(lbl_nro_pregunta)

        '        Dim chk1 As New Anthem.CheckBox
        '        AddHandler chk1.CheckedChanged, AddressOf chk
        '        chk1.SkinID = rp.DtTable.Rows(i).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(i).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              
        '        celda2.Controls.Add(chk1)

        '        lbl_r1.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta1").ToString
        '        lbl_r2.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta2").ToString
        '        lbl_r3.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta3").ToString
        '        lbl_r4.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta4").ToString
        '        lbl_r5.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta5").ToString

        '        lbl_r1.UpdateAfterCallBack = True
        '        lbl_r2.UpdateAfterCallBack = True
        '        lbl_r3.UpdateAfterCallBack = True
        '        lbl_r4.UpdateAfterCallBack = True
        '        lbl_r5.UpdateAfterCallBack = True

        '        celdar1.Controls.Add(lbl_r1)
        '        celdar2.Controls.Add(lbl_r2)
        '        celdar3.Controls.Add(lbl_r3)
        '        celdar4.Controls.Add(lbl_r4)
        '        celdar5.Controls.Add(lbl_r5)

        '        Dim fl As New TableRow
        '        fl.Cells.Add(celda)
        '        fl.Cells.Add(celda2)
        '        fl.Cells.Add(celdar1)
        '        fl.Cells.Add(celdar2)
        '        fl.Cells.Add(celdar3)
        '        fl.Cells.Add(celdar4)
        '        fl.Cells.Add(celdar5)

        '        tbRespuesta.Rows.Add(fl)

        '        tbRespuesta.CellPadding = 4
        '        tbRespuesta.CellSpacing = 4

        '        tbRespuesta.UpdateAfterCallBack = True
        '        celda0.Controls.Add(tbRespuesta)
        '        fila1.Cells.Add(celda0)

        '        tbl_preguntas.Rows.Add(fila1)
        '    Next

        '    tbl_preguntas.UpdateAfterCallBack = True
        'End If

    End Sub


    'Sub GeneraAlternativaCorrectaConImagen(ByRef rp As DotNetResponse.SQLPersistence)
    '    If rp.TieneDatos Then


    '        Dim i As Integer
    '        Dim tbRespuesta As New Anthem.Table

    '        For i = 0 To rp.DtTable.Rows.Count - 1
    '            Dim celda0 As New TableCell
    '            celda0.ColumnSpan = 2

    '            Dim celda As New TableCell
    '            Dim celda2 As New TableCell

    '            Dim celdar1 As New TableCell
    '            Dim celdar2 As New TableCell
    '            Dim celdar3 As New TableCell
    '            Dim celdar4 As New TableCell
    '            Dim celdar5 As New TableCell

    '            celdar1.HorizontalAlign = HorizontalAlign.Left
    '            celdar2.HorizontalAlign = HorizontalAlign.Left
    '            celdar3.HorizontalAlign = HorizontalAlign.Left
    '            celdar4.HorizontalAlign = HorizontalAlign.Left
    '            celdar5.HorizontalAlign = HorizontalAlign.Left


    '            Dim fila1 As New TableRow
    '            Dim lbl_nro_pregunta As New Anthem.Label
    '            Dim lbl_r1 As New Anthem.Image
    '            Dim lbl_r2 As New Anthem.Image
    '            Dim lbl_r3 As New Anthem.Image
    '            Dim lbl_r4 As New Anthem.Image
    '            Dim lbl_r5 As New Anthem.Image

    '            lbl_nro_pregunta.Text = rp.DtTable.Rows(i).Item("i_fila").ToString

    '            celda.Controls.Add(lbl_nro_pregunta)

    '            Dim chk1 As New Anthem.CheckBox
    '            AddHandler chk1.CheckedChanged, AddressOf chk
    '            chk1.SkinID = rp.DtTable.Rows(i).Item("P_RESPUESTA").ToString & "," & rp.DtTable.Rows(i).Item("K_PREGUNTA").ToString 'P_RESPUESTA , 'K_PREGUNTA              
    '            celda2.Controls.Add(chk1)

    '            lbl_r1.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta1").ToString
    '            lbl_r2.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta2").ToString
    '            lbl_r3.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta3").ToString
    '            lbl_r4.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta4").ToString
    '            lbl_r5.ImageUrl = rp.DtTable.Rows(i).Item("s_ruta5").ToString

    '            lbl_r1.UpdateAfterCallBack = True
    '            lbl_r2.UpdateAfterCallBack = True
    '            lbl_r3.UpdateAfterCallBack = True
    '            lbl_r4.UpdateAfterCallBack = True
    '            lbl_r5.UpdateAfterCallBack = True

    '            celdar1.Controls.Add(lbl_r1)
    '            celdar2.Controls.Add(lbl_r2)
    '            celdar3.Controls.Add(lbl_r3)
    '            celdar4.Controls.Add(lbl_r4)
    '            celdar5.Controls.Add(lbl_r5)

    '            Dim fl As New TableRow
    '            fl.Cells.Add(celda)
    '            fl.Cells.Add(celda2)
    '            fl.Cells.Add(celdar1)
    '            fl.Cells.Add(celdar2)
    '            fl.Cells.Add(celdar3)
    '            fl.Cells.Add(celdar4)
    '            fl.Cells.Add(celdar5)

    '            tbRespuesta.Rows.Add(fl)

    '            tbRespuesta.CellPadding = 4
    '            tbRespuesta.CellSpacing = 4

    '            tbRespuesta.UpdateAfterCallBack = True
    '            celda0.Controls.Add(tbRespuesta)
    '            fila1.Cells.Add(celda0)

    '            tbl_preguntas.Rows.Add(fila1)
    '        Next

    '        tbl_preguntas.UpdateAfterCallBack = True
    '    End If

    'End Sub

#End Region
    Sub chk(ByVal sender As Object, ByVal e As EventArgs)

    End Sub
    Protected Sub LinkButton1_Click1(ByVal sender As Object, ByVal e As EventArgs)
        Dim rpexec As New DotNetResponse.SQLPersistence
        ' Dim Cargar As New DalAppTestBuilder.TB_GENERICA
        ' Cargar.GetDataTable(rpexec, "select S_NOMBRE_SECCION , I_PUNTOS ,I_NRO_SECCION, s_observacion   from TB_PRUEBA_DISENO_SECCION where P_SECCION =" & DirectCast(sender, Anthem.LinkButton).CommandArgument)

        If rpexec.TieneDatos Then

            ViewState("P_SECCION") = DirectCast(sender, Anthem.LinkButton).CommandArgument
            lbl_Titulo_seccion.Text = rpexec.DtTable.Rows(0).Item("S_NOMBRE_SECCION")
            lbl_puntos_seccion.Text = rpexec.DtTable.Rows(0).Item("I_PUNTOS")

            lbl_Titulo_seccion.UpdateAfterCallBack = True
            lbl_puntos_seccion.UpdateAfterCallBack = True

            lbl_Titulo_seccion.Text = rpexec.DtTable.Rows(0).Item("S_NOMBRE_SECCION")
            lbl_puntos_seccion.Text = rpexec.DtTable.Rows(0).Item("I_PUNTOS")

            lbl_Titulo_seccion.UpdateAfterCallBack = True
            lbl_puntos_seccion.UpdateAfterCallBack = True

            GetPreguntas()

        End If

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Busca_objeto(tbl_preguntas)
    End Sub

    Sub Busca_objeto(ByVal ctl As Control)
        If ctl.Controls.Count > 0 Then
            Dim i As Integer
            For i = 0 To ctl.Controls.Count - 1
                Busca_objeto(ctl.Controls(i))
            Next
        Else
            If ctl.GetType.ToString = "Anthem.CheckBox" Then
                'DirectCast(ctl, Anthem.CheckBox).Checked
                GrabaRespuesta(ctl.SkinID.Split(",")(0), ctl.SkinID.Split(",")(1), ViewState("ID_PRUEBA_EJECUCION"), DirectCast(ctl, Anthem.CheckBox).Checked.ToString)

            End If
            If ctl.GetType.ToString = "Anthem.TextBox" Then
                'DirectCast(ctl, Anthem.CheckBox).Checked
            End If

        End If
    End Sub

    Sub GrabaRespuesta(ByVal FK_RESPUESTA As Decimal, ByVal FK_PREGUNTA As Decimal, ByVal FK_PRUEBA_EJECUCION As Decimal, ByVal S_VALOR_RESPUESTA As String)
        'SP_INSERTA_PRUEBA_EJECUCION_RESPUESTA
        '@FK_RESPUESTA as numeric(18,0)
        ', @FK_PREGUNTA as numeric(18,0)
        ', @FK_PRUEBA_EJECUCION as numeric(18,0)
        ', @S_VALOR_RESPUESTA as varchar(4000)


        Dim Rpexec As New DotNetResponse.SQLPersistence
        Rpexec.StoredProcedure = "SP_INSERTA_PRUEBA_EJECUCION_RESPUESTA"
        Rpexec.AddParametro(FK_RESPUESTA)
        Rpexec.AddParametro(FK_PREGUNTA)
        Rpexec.AddParametro(FK_PRUEBA_EJECUCION)
        Rpexec.AddParametro(S_VALOR_RESPUESTA)

        Dim Exec As New DotNetDal.SQLPersistence(True, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Exec.ExecuteNonQuery(Rpexec)
        Exec.Commit()
        Exec.Dispose()

        If Rpexec.Errores Then
            'enviar mensaje de error
        End If

    End Sub
 
    Protected Sub GridSecciones_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridSecciones.SelectedIndexChanged

        Dim rpexec As New DotNetResponse.SQLPersistence
        'Dim Cargar As New DalAppTestBuilder.TB_GENERICA
        'Cargar.GetDataTable(rpexec, "select S_NOMBRE_SECCION , I_PUNTOS ,I_NRO_SECCION, s_observacion   from TB_PRUEBA_DISENO_SECCION where P_SECCION =" & GridSecciones.SelectedItem.Cells(2).Text)

        If rpexec.TieneDatos Then

            ViewState("P_SECCION") = GridSecciones.SelectedItem.Cells(2).Text
            lbl_Titulo_seccion.Text = rpexec.DtTable.Rows(0).Item("S_NOMBRE_SECCION")
            lbl_puntos_seccion.Text = rpexec.DtTable.Rows(0).Item("I_PUNTOS")

            lbl_Titulo_seccion.UpdateAfterCallBack = True
            lbl_puntos_seccion.UpdateAfterCallBack = True

            lbl_Titulo_seccion.Text = rpexec.DtTable.Rows(0).Item("S_NOMBRE_SECCION")
            lbl_puntos_seccion.Text = rpexec.DtTable.Rows(0).Item("I_PUNTOS")

            lbl_Titulo_seccion.UpdateAfterCallBack = True
            lbl_puntos_seccion.UpdateAfterCallBack = True

            GetPreguntas()

        End If
    End Sub
End Class